package com.yj.springbootevent;

import com.yj.springbootevent.demo.MyAnnotationEventListener;
import com.yj.springbootevent.demo.MyEventPublisher;
import com.yj.springbootevent.event.MyApplicationEventPublisher;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

import java.util.HashMap;

@SpringBootApplication
public class SpringBootEventApplication {

    public static void main(String[] args) {
        ConfigurableApplicationContext context = SpringApplication.run(SpringBootEventApplication.class, args);

        MyEventPublisher publisher = context.getBean(MyEventPublisher.class);

        // 发布携带数据的事件。
        HashMap<String, Object> map = new HashMap<>();
        map.put("name","yijian");
        map.put("age",18);

        publisher.publishEvent(map);

    }

}
